<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="Content-Script-Type" content="text/javascript" />
		<meta http-equiv="Content-Style-Type" content="text/css" />
		<title>コントロールパネル</title>
		<link rel="stylesheet" href="./assets/styles/default.css" type="text/css" />
		<link rel="stylesheet" href="./assets/styles/ui-lightness/ui.all.css" type="text/css" />
		<link rel="stylesheet" href="./assets/styles/dialog.css" type="text/css" />
		<script src="assets/scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
		<script src="assets/scripts/jquery-ui-1.7.3.custom.min.js" type="text/javascript"></script>
		<script src="assets/scripts/ui/ui.dialog.js" type="text/javascript"></script>
		<script src="assets/scripts/menu.js" type="text/javascript"></script>
		<script src="assets/scripts/table.js" type="text/javascript"></script>
		<script src="assets/scripts/jquery.scrollTo-1.4.2-min.js" type="text/javascript"></script>
		<script type="text/javascript" src="./assets/scripts/editor.js"></script>
		<script type="text/javascript" src="./assets/scripts/ui/ui.datepicker.js"></script>
		<script type="text/javascript" src="./assets/scripts/ui/ui.core.js"></script>
		<style type="text/css">
input,
.text,
textarea {
	*font-family: "MS Pゴシック","ＭＳ Ｐゴシック","MS P Gothic";
	line-height:120%;
	height:25px;
	width:90%;
}
th span{width:80px};
input.btnleft{	text-align:	left;};
table.formTable tr {
	height:38px;
}

table.formTable th {
	padding: 0px 0px 0px 0px;
	margin:0 0 0 0;
	width:100px;
	vertical-align: top;
	text-align:center;
	border: 1px solid #A0A0A0;
}

.errmsg{color:red;width:100%;};
.all_div {
  width:100%;
  float: left;  /* 左方向にフロート */
  position:relative;
}
 
/* 左カラム固定・右カラム可変 */
.l_div {
  width:28.5%;
  float: left;  /* 左方向にフロート */

}
 
.r_div {
/*float: right;   右方向にフロート */
  width:71%;
  z-index:300;
  overflow-x:auto;
  overflow-y:hidden;
}
 	</style>
		<script type="text/javascript">
		$(function() {
			$('.message').fadeIn("slow");
			$('.btn_regist').click(function(){
				if( confirm('登録してよろしいですか？') ){
					document.fm.mode.value = 'input';
					document.fm.submit();
				}
			});
			
			$('.btn_return').click(function(){
				location.href = "mmatrix_index.php?hist=2";
			});
			/*
			$("#block_cd").change(function(){
				document.fm.block_name.value = $("#block_cd").find("option:selected").text();
			});
			
			$("#local_cd").change(function(){
				document.fm.local_name.value = $("#local_cd").find("option:selected").text();
			});
			*/
			$('.text_date').live('click',function(){
				$(this).datepicker({
					changeMonth: true,
					changeYear: true,
					dateFormat: 'yy/mm/dd(D)'
				});
			});
			
			//*******************
			$(".exp_ins").live('change',function(){
				//alert($(this).val());
				var idNo = $(this).parents('form:first').attr("id").split("_")[0];
				
				var index =  $('#' + idNo +'_fm [name^=exp_ins_flg]').index($(this));
				
				if ($(this).val() == "9") {
					$('#' + idNo +'_fm [name^=exp_ins_week]').eq(index).val("{{$forms.flier_date}}");
					//$('#' + idNo +'_fm [name^=exp_ins_week]').eq(index).attr("disabled", "disabled");
				} else {
					//$('#' + idNo +'_fm [name^=exp_ins_week]').eq(index).removeAttr("disabled");
				}
			});
			/*
			$(".area_id").change(function(){
				//document.fm.local_name.value = $("#local_cd").find("option:selected").text();
				var text = $(this).find("option:selected").text()
				var idNo = $(this).parents('form:first').attr("id").split("_")[0];
				var index =  $('#' + idNo +'_fm [name^=area_id]').index($(this));
				$('#' + idNo +'_fm [name^=nmarea]').eq(index).attr("value", text);
			});
			*/
			$('.btn_savetb').live('click',function(){
				if( confirm('更新してよろしいですか？') ){
					var idNo =  $(this).attr("id").split("_")[0];
					var max_title_nums = {{ $forms.maxgroupid }};
					if ($('#' + idNo +'_fm [name=groupid]').val() > max_title_nums ) {
						$('#' + idNo +'_fm [name=groupid]').attr("value",max_title_nums);
					}
					$('#' + idNo +'_fm [name=mode]').attr("value",'input');
					$('#' + idNo +'_fm').submit();
				}
			});

			$('.btn_addtr').live('click',function(){
				add_tr($(this).attr("id"));
			});
			
			$('#btn_addli').click(function(){
				var strHtml = $("#divlibase").html()
				var regS = new RegExp("zzz","gi");
				strHtml = strHtml.replace(regS, g_all_title_nums)
				$("#ularea").append(strHtml);
				$.scrollTo('#' + g_all_title_nums+'_fm',10);
				g_all_title_nums = g_all_title_nums*1 + 1;
			});
			{{ if ($group_index)  }}
			$.scrollTo('#{{ $group_index }}_fm');
			{{ /if }}
		});
		
		function add_tr(vid) {
			var idNo =  vid.split("_")[0];
			var strTd = $("#zzz_tab_r tr").eq(1).html();
			
			$('#'+ idNo +'_tab_r' ).append('<tr>' + strTd +'</tr>');
			
			var strTd = $("#zzz_tab_l tr").eq(1).html();
			$('#'+ idNo +'_tab_l' ).append('<tr>' + strTd +'</tr>');
		}
		var g_all_title_nums =  {{ $forms.maxgroupindex }}; 
		//--------------------------------------------------------------------------
		
	var gpop_obj   = null;
	var ginnerdiv  = false;
	var ginnerdivP = false;
	$(function(){

		$('.pp1').live('focus',function(){
			disppop( $(this), "#pop1");
		});
		
		$('.pp2').live('focus',function(){
			disppop( $(this), "#pop2");
		});
		
		$('.pp3').live('focus',function(){
			disppop( $(this), "#pop3");
		});
		
		$('.ppp').live('focus',function(){
			disppop_pt( $(this));
		});
		document.onclick=function(e){ 
			var e = e ? e : window.event; 
			var tar = e.srcElement || e.target;
			if (!ginnerdiv) {
				 //alert($(tar).attr("class").indexOf("pp1")); 
				if ( ( $(tar).attr("class").indexOf("pp1") <= 0  ) &&
					 ( $(tar).attr("class").indexOf("pp2") <= 0  ) &&
					 ( $(tar).attr("class").indexOf("pp3") <= 0  ) ){ 
					hpa();
				} 
			}
			if (!ginnerdivP) {
				if (  ( $(tar).attr("class").indexOf("ppp") <= 0  ) ){ 
					hpt();
				} 
			}
		} 
		
	    $("#pop_cp").live("mouseenter",function(){
	    	ginnerdiv = true;
	    });
	    $("#pop_cp").live("mouseleave",function(){
	    	ginnerdiv = false
	    });
	    $("#pop_pt").live("mouseenter",function(){
	    	ginnerdivP = true;
	    });
	    $("#pop_pt").live("mouseleave",function(){
	    	ginnerdivP = false
	    });
	});
	
	function disppop_pt(obj) {
		var offset =  obj.offset();
		gpop_obj   =  obj;
		var top = offset.top + obj.height() + 8 ;
		var bottom = document.body.scrollTop+document.body.clientHeight;
		if  (top + 100 >bottom) {
			top = bottom - 100;
		}
		var left  = offset.left + obj.width() - 115 ; 
		$('#pop_pt').css({
				'display':'block',
				'top': top +'px',
				'left':left+'px',
				'position':'absolute'
		});
	}
	
	function disppop(obj, val) {
		$('#pop_cp').html($(val).html() )
		var offset =  obj.offset();
		gpop_obj   =  obj;
		var top = offset.top + obj.height() + 8 ;
		var bottom = document.body.scrollTop+document.body.clientHeight;
		if  (top + 100 >bottom) {
			top = bottom - 100;
		}
		var left  = offset.left + obj.width() - 115 ; 
		$('#pop_cp').css({
				'display':'block',
				'top': top +'px',
				'left':left+'px',
				'position':'absolute'
		});
	}
	
	function hpa() {
		$("#pop_cp").hide();
		ginnerdiv = false;
	}
	
	function hpt() {
		$("#pop_pt").hide();
		ginnerdivP = false;
	}
	
	function spa(text) {
		hpa();
		gpop_obj.attr("value",text);
		/*
		$("#"+gpatt_id).attr("value", text);
		
		var id  = gpatt_id.replace("nm", "")
		$("#" + id).attr("value", val);
		var index = id.split("_")[2] * 1;
		theID = "n" + id;
		var nums = "";
		if (val != "" ) {
			nums = getPNums($('#fm [name^=shop_cd]').eq(index).attr("value"),val) ;
		}
		
		$('#'+ theID ).val(nums);
		*/
		/*
		try{
			var group_no =  $("#"+gpatt_id).attr("ref") ;
			if (group_no) {
				 $("."+group_no).each(function(){
					   var patt_id =  $(this).attr("id") ;
					   $("#"+gpatt_id).attr("value", text);
				});
			}
		} catch(e) {
		}
		*/
	}
	function spp(text) {
		hpt();
		gpop_obj.attr("value",text);
	}
		</script>
		
	</head>
<body id="">
{{ $menu }}
{{ $logout }}
		<div id="container"><div class="wrapper">
			<h2>マトリックスマスター管理</h2>
			<ul class="submenu clearfix">
				<li><a href="mmatrix_index.php">マトリックス情報一覧</a></li>
				{{if  (!$isG7)  }}<li><a href="mmatrix_form.php">マトリックス情報登録</a></li> {{ /if }}
				<li>チラシマトリックス設定</li>
				{{if  (!$isG7)  }}<li><a href="mmatrix_master_index.php">コードマスタ</a></li>{{ /if }}
			</ul>
			<h3>チラシマトリックス設定{{ if $phase == 'complete' }}完了{{ /if }}</h3>
{{ if $phase == 'input' }}
			<p class="message">内容</p>
<p>■{{ $forms.year4 }}年度 &nbsp;  第{{ $forms.week_cd }}周&nbsp; {{ if $forms.week_seq != '0'  }}  第{{ $forms.week_seq }}回&nbsp;  {{ /if }} {{ $forms.flier_date }}</p>
<p  class="btnright" >				
	<button type="button" id="btn_addli" class="submit"><span>新規チラシタイトル追加</span></button>&nbsp;&nbsp;
</p>
<ul id="ularea" style="width:100%" >
{{ foreach from=$forms.groupid key=gk item=gv name="member" }}
<li style="width:100%" >
<form name="{{ $gv }}_fm" id= "{{ $gv }}_fm" action="mmatrix_form_ver.php" method="post">
<div class="errmsg"> {{ $forms[$gk].h.errmsg|escape }} </div>
<div class = "all_div">
タイトル ：<input type="text" name="title" class="text" style="width:150px" value="{{ $forms[$gk].h.title|escape }}" />&nbsp;&nbsp;&nbsp;
色 ：<input type="text" name="color" class="text"  style="width:150px" value="{{ $forms[$gk].h.color|escape }}" />&nbsp;&nbsp;&nbsp;
売り方 ：<input type="text" name="sale_name" class="text"  style="width:150px" value="{{ $forms[$gk].h.sale_name|escape }}" />&nbsp;&nbsp;&nbsp;
継続/新規 ：{{ html_options class='oper' name='oper' options=$opers  selected=$forms[$gk].h.oper|escape }}&nbsp;&nbsp;&nbsp;
 {{ if $forms[$gk].h.u_time  }}最終更日時 ： {{ $forms[$gk].h.u_time }} {{ /if }}
 </div>
 <!--  style="table-layout:fixed;word-wrap:break-word;word-break;break-all;"-->
 <div class="l_div"> 
 <table class="formTable" id = "{{ $gv }}_tab_l" style="table-layout:fixed;word-wrap:break-word;word-break:break-all;" >
  <tr><th style="width:38px"><span>サイズ</span></th><th style="width:38px"><span>版番号</span></th>
  <th style="width:38px"><span>制作<br>業者</br></span></th><th style="width:38px"><span>印刷<br>業者</br></span></th></tr>
  {{ foreach from=$forms[$gk].d key=kk item=vv name="member" }}
  <tr><td >{{ html_options  name='size[]' options=$size selected=$vv.size class="text" }}
	<input type="hidden" name="id[]" value="{{ $vv.id|escape }}"/></td>
	<td> <input type="text" name="verno[]"  class="text" value="{{ $vv.verno|escape }}"></input></td>
	<td> <input type="text" name="contractor[]"  class="text pp1" value="{{ $vv.contractor|escape }}" /></td>
	<td> <input type="text" name="print[]"  class="text pp2" value="{{ $vv.print|escape }}" /></td></tr>
   {{ /foreach }}
 </table>
 </div>
<div class="r_div"  s> 
	<table class="formTable" id = "{{ $gv }}_tab_r"   style="width:1200px">
	<tr> <th style="width:100px"><span>エリア</span></th><th style="width:100px"><span>地域新聞名</span></th>
		<th style="width:100px"><span>管理NO<br>オモテ</span></th> <th style="width:100px"><span>管理NO<br>ウラ</span></th>
		<th style="width:100px"><span>前週下版</span></th><th style="width:100px"><span>MAP</span></th>
		<th style="width:100px"><span>割引券</span></th>
		<th style="width:100px"><span >例外折込<br>フラグ</span></th><th style="width:100px"><span>例外折込曜日</span></th>
		<th style="width:100px"><span>備考欄</span></th><th style="width:100px"><span>使用フラグ</span></th>
		<th style="width:100px"><span>印刷業者備考</span></th>
	</tr>
 {{ foreach from=$forms[$gk].d key=kk item=vv name="member" }}
 	<tr> <td> <input type="text" name="area[]" class="text pp3" value="{{ $vv.area|escape }}" /></td>
	<td> <input type="text" name="pattern_name[]" class="text ppp" value="{{ $vv.pattern_name|escape }}" /></td>
	<td> <input type="text" name="mano_out[]" class="text" value="{{ $vv.mano_out|escape }}" /> </td>
	<td> <input type="text" name="mano_in[]" class="text" value="{{ $vv.mano_in|escape }}" /></td>
	<td> <input type="text" name="perweekver[]" class="text" value="{{ $vv.perweekver|escape }}" /></td>
	<td> {{ html_options class='sort' name='map[]'  options=$map_sort selected=$vv.map }}</td>
	<td> <input type="text" name="saletickt[]" class="text" value="{{ $vv.saletickt|escape }}" /></td>
	<td>{{ html_options  name='exp_ins_flg[]' options=$exp_ins_flg  selected=$vv.exp_ins_flg class="text exp_ins"   }}</td>
	
	<td> <input type="text" name="exp_ins_week[]" class="text_date" value="{{ $vv.exp_ins_week|escape }}" /> </td>
	
	<td> <input type="text" name="memo[]" class="text" value="{{ $vv.memo|escape }}" /></td>
	<td>{{ html_options  name='user_flag[]' options=$user_flag selected=$vv.user_flag class="text" }}</td>
	<td> <input type="text" name="memoprinter[]" class="text" value="{{ $vv.memoprinter|escape }}" /></td></tr>
 {{ /foreach }}
	</table>
	<br>
</div>
	<input type="hidden" name="mode" />
	<input type="hidden" name="groupid" value="{{ $gv }}" />
	<input type="hidden" name="matrix_cd" value="{{ $forms.matrix_cd }}" />
<div class = "all_div">
	<p  class="btnleft" >
		<button type="button" class="btn_addtr"  id="{{ $gv }}_atr" class="submit btnleft"><span>関連チラシマトリックス追加</span></button><br>
		<button type="button" class="btn_savetb"  id="{{ $gv }}_stb" class="submit btnleft"><span>上記タイトル保存</span></button>
	</p>
	<br>
</div>
	</form>
</li>
{{ /foreach }}
</ul>
<div id = "divlibase" style="display:none">
<li>
<form name="zzz_fm" id= "zzz_fm" action="mmatrix_form_ver.php" method="post">
<div class="errmsg">  </div>
<div class = "all_div">
タイトル ：<input type="text" name="title" class="text" style="width:150px"  />&nbsp;&nbsp;&nbsp;
色 ：<input type="text" name="color" class="text"  style="width:150px" />&nbsp;&nbsp;&nbsp;
売り方 ：<input type="text" name="sale_name" class="text"  style="width:150px"  />&nbsp;&nbsp;&nbsp;
継続/新規 ：{{ html_options class='oper' name='oper' options=$opers  }}&nbsp;&nbsp;&nbsp;
</div>
 <div class="l_div"> 
 <!--  
 <table class="formTable" id = "zzz_tab_l" style="table-layout:fixed;word-wrap:break-word;word-break;break-all;">
 <tr><th style="width:50px"><span>サイズ</span></th><th style="width:50px"><span>業者<br>&nbsp;</br></span></th></tr>
  <tr><td >{{ html_options  name='size[]' options=$size selected=$vv.size class="text" }}
	<input type="hidden" name="id[]" /></td>
	<td>{{ html_options  name='contractor[]' options=$contractor  class="text" }}</td></tr>
 </table>
 -->
  <table class="formTable" id = "zzz_tab_l"  style="table-layout:fixed;word-wrap:break-word;word-break:break-all;" >
  <tr><th style="width:38px"><span>サイズ</span></th><th style="width:38px"><span>版番号</span></th>
  <th style="width:38px"><span>制作<br>業者</br></span></th><th style="width:38px"><span>印刷<br>業者</br></span></th></tr>
  <tr><td >{{ html_options  name='size[]' options=$size  class="text" }}
	<input type="hidden" name="id[]" /></td>
	<td> <input type="text" name="verno[]"  class="text" ></input></td>
	<td> <input type="text" name="contractor[]"  class="text pp1"  /></td>
	<td> <input type="text" name="print[]"  class="text pp2"  /></td></tr>
 </table>
 
 </div>
<div class="r_div"> 
<table class="formTable"  id = "zzz_tab_r"   style="width:1200px">
	<tr> <th style="width:100px"><span>エリア</span></th><th style="width:100px"><span>地域新聞名</span></th>
		<th style="width:100px"><span>管理NO<br>オモテ</span></th> <th style="width:100px"><span>管理NO<br>ウラ</span></th>
		<th style="width:100px"><span>前週下版</span></th><th style="width:100px"><span>MAP</span></th>
		<th style="width:100px"><span>割引券</span></th>
		<th style="width:100px"><span >例外折込<br>フラグ</span></th><th style="width:100px"><span>例外折込曜日</span></th>
		<th style="width:100px"><span>備考欄</span></th><th style="width:100px"><span>使用フラグ</span></th>
		<th style="width:100px"><span>印刷業者備考</span></th>
	</tr>
	 <tr> <td> <input type="text" name="area[]" class="text pp3" /></td>
	<td> <input type="text" name="pattern_name[]" class="text ppp"  /></td>
	<td> <input type="text" name="mano_out[]" class="text"  /> </td>
	<td> <input type="text" name="mano_in[]" class="text"  /></td>
	<td> <input type="text" name="perweekver[]" class="text"  /></td>
	<td> {{ html_options class='sort' name='map[]'  options=$map_sort selected=1 }}</td>
	<td> <input type="text" name="saletickt[]" class="text"  /></td>
	<td>{{ html_options  name='exp_ins_flg[]' options=$exp_ins_flg  selected=9 class="text exp_ins"   }}</td>
	<td> <input type="text" name="exp_ins_week[]" class="text_date" value="{{$forms.flier_date}}" /> </td>
	<td> <input type="text" name="memo[]" class="text"/></td>
	<td>{{ html_options  name='user_flag[]' options=$user_flag class="text" }}</td>
	<td> <input type="text" name="memoprinter[]" class="text"  /></td></tr>
	</tr>
	</table>
</div>
	<input type="hidden" name="mode" />
	<input type="hidden" name="groupid" value="zzz" />
	<input type="hidden" name="matrix_cd" value="{{ $forms.matrix_cd }}" />
	<div class = "all_div">
	<p  class="btnleft" >
		<button type="button" class="btn_addtr"  id="zzz_atr" class="submit btnleft"><span>関連チラシマトリックス追加</span></button><br>
		<button type="button" class="btn_savetb"  id="zzz_stb" class="submit btnleft"><span>上記タイトル保存</span></button>
	</p>
	<br>
	<div>
	</form>
</li>
</div>	
<div id="dialog" >
</div>
 
{{ /if }}
<!--  
{{ if $phase == 'complete' }}
	<p class="message">{{ $message }}</p>
	<ul>
	{{ if $forms.id != '' }}
					<li>>> <a href="mmatrix_index.php?hist=2">一覧ページに戻る</a></li>
	{{ else }}
					<li>>> <a href="mmatrix_index.php">一覧ページに戻る</a></li>
	{{ /if }}
					<li>>> <a href="mmatrix_form.php">新規登録</a></li>
	{{ if $forms.id != '' }}
					<li>>> <a href="mmatrix_form.php?id={{ $forms.id }}">更新</a></li>
	{{ /if }}
	</ul>
{{ /if }}
-->	
</div>
</div>
<!-- <tr><td align="right" ><button type="button" onclick="javascript:hpa()" ><span>閉じる</span></button>&nbsp;&nbsp;</td></tr> -->
<div id="pop_cp" style = "width:130px; height:300px;background:#eeeecc;  overflow-y:scroll;display:none" > </div>
 <div id="pop1" style = "display:none" >
 <table width="98%" border="0" cellspacing="2" cellpadding="2" style="font-size:12px; line-height:17px;">
 {{ foreach from=$contractors key=k item=v name="cs" }}
   <tr><td align="left"><b><a href="javascript:void(0)" onclick="javascript:spa('{{$k}}')" > {{$k}} </a></b></td></tr>
 {{ /foreach }}
 </table>
 </div>
 
 <div id="pop2" style = "display:none" >
 <table width="98%" border="0" cellspacing="2" cellpadding="2" style="font-size:12px; line-height:17px;">
  <tr>
  
 {{ foreach from=$prints key=k item=v name="cs" }}
   <tr><td align="left"><b><a href="javascript:void(0)" onclick="javascript:spa('{{$k}}')" > {{$k}} </a></b></td></tr>
 {{ /foreach }}
 </table>
 </div>
 <div id="pop3" style = "display:none" >
 <table width="98%" border="0" cellspacing="2" cellpadding="2" style="font-size:12px; line-height:17px;">
 {{ foreach from=$areas key=k item=v name="cs" }}
   <tr><td align="left"><b><a href="javascript:void(0)" onclick="javascript:spa('{{$v}}')" > {{$v}} </a></b></td></tr>
 {{ /foreach }}
 </table>
 </div>

<div id="pop_pt" style = "width:130px; height:300px;background:#eeeecc;  overflow-y:scroll;display:none" >
<table width="98%" border="0" cellspacing="2" cellpadding="2" style="font-size:12px; line-height:17px;">
  <tr>
 {{ foreach from=$patterns key=k item=v name="cs" }}
   <tr><td align="left"><b><a href="javascript:void(0)" onclick="javascript:spp('{{$v}}')" > {{$v}} </a></b></td></tr>
 {{ /foreach }}
 </table>
 </div>


<div class = "all_div">{{ $footer }}</div>
	</body>
</html>